package com.ghost.alibabaghost.dao.mapper.sys;

import com.ghost.alibabaghost.dao.dataobject.sys.SysUserRoleDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Description:
 *
 * @author 075aec19-54c7-435e-9a8a-df7078bd95d7
 * Date 2022-01-14
 */
@Mapper
public interface SysUserRoleMapper {

    /**
     *
     * @param userId
     * @return
     */
    @Select("select id, user_id, role_id from sys_user_role where user_id = #{userId}")
    SysUserRoleDO queryRoleByUserId(Integer userId);

    /**
     *
     * @param sysUserRoleDO
     * @return
     */
    @Insert(value = "insert into sys_user_role values (null ,#{userId},#{roleId})")
    Integer insertUserRole(SysUserRoleDO sysUserRoleDO);

    /**
     *
     * @param sysUserRoleDO
     * @return
     */
    @Update(value = "update sys_user_role set role_id = #{roleId} where user_id = #{userId}")
    Integer updateByUserId(SysUserRoleDO sysUserRoleDO);
}
